import os
from datetime import datetime

from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class Base:

    #截屏
    SCREENSHOT_OIR={
        os.path.join(os.path.join(os.path.join(r'C:\Users\Kaka\PycharmProjects\PythonProject9.3zhoukao\Base.py')))
    }

    def __init__(self,driver:WebDriver,timeout:int=10):

        self.driver=driver
        self.wait=WebDriver('%Y%m%d_%H%M%S_f',r'C:\Users\Kaka\PycharmProjects\PythonProject9.3zhoukao\Base.py')

    #定位元素
    def find_element(self,loc):
        try:
            self.find_element(loc)
        except Exception as e:
            print(e)
    #输入文本
    def send_keys(self,loc,info):
        self.find_element(loc).send_keys(info)
    #读取内容
    def read_text(self,loc):
        self.find_element(loc).text()

    def get_URL(self,url):
        self.driver.get(url)

    def click_content(self,loc):
        self.find_element(loc).click()

    def timeout(self,driver,loc,time:int=10):
        self.driver=driver
        self.wait= (WebDriverWait.until(self.find_element(loc),EC.WebDriver.find_element(time)))

    def select(self,loc):
        ele=self.select(loc)
        ele.clear()
        return ele





